package demo17;

public class Test {

    public int takeAttendance(int[] records) {
        int n = records.length;
        int left = 0, right = n - 1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (records[mid] == mid) left = mid + 1;
            else right = mid;
        }
        if (left == records[n - 1]) return left + 1;
        return left;
    }


    public int findMin(int[] nums) {
        int n = nums.length;
        int left = 0, right = n - 1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] > nums[n - 1]) left = mid + 1;
            else right = mid;
        }
        return nums[left];
    }

}
